self.onmessage = ({data}) => {
    const {features} = data
    const result = []
    if (features == 0) {
        self.postMessage(result)
    } else {
        features.forEach(({geometry, properties}) => {
            const {type, coordinates} = geometry
            const points = geometryFn[type](coordinates);
            result.push({ type, properties, points })
        })
    }
    self.postMessage(result)
    self.close()
}

const polygonResolve = coordinates => {
    let points = []
    coordinates.forEach(coords => {
        coords.forEach(coord => {
            points = points.concat(coord)
        })
    })
    return points
}

const pointResolve = coordinates => coordinates

const polylineResolve = coordinates => {
    let points = []
    coordinates.forEach(coords => {
        points = points.concat(coords)
    })
    return points
}

const multiPolylineResolve = coordinates => {
    let points = []
    coordinates.forEach(coords => {
        coords.forEach(coord => {
            points = points.concat(coord)
        })
    })
    return points
}

//geometry图元处理函数
const geometryFn = {
    //面
    Polygon: polygonResolve,
    MultiPolygon: polygonResolve,
    // 点
    Point: pointResolve,
    MultiPoint: pointResolve,
    // 线
    LineString: polylineResolve,
    MultiLineString: multiPolylineResolve
}

